04. For-In Loops
For-In Loops
Question:
Start Quiz:
Solution:
INSTRUCTOR NOTE:
Clarification
Use forEach or for to iterate over arrays like:
countries = ['Argentina', 'China', 'England'];Use
for-in to loop over objects like countries = {'country1':'Argentina', 'country2':'China','country3':'England'};being careful to wrap the content of the
for-in in a conditional statement that tests if the key is part of the object: myObj = {'country1':'Germany', 'country2':'Argentina'}; for (key in myObj){ if (myObj.hasOwnProperty(key)) { console.log(myObj[key]); } }</pre>
For more information, please refer to the loop section of the Udacity Front End Style Guide.:last
The
:lastjQuery selector returns the final element in a list that matches whatever precedes it.
So forwork-entry:last, if there are 3work-entryelements, it will only return the 3rd one.
If you're interested, you can read more about jQuery's:lastselector here.
For this quiz you'll work with theindex.htmlandjs/resumeBuilder.jsfiles from the résumé project's Github repository you downloaded earlier in this lesson. Editjs/resumeBuilder.jsin your text editor, and view the results by openingindex.htmlin the browser of your choice. Note that the HTML needed is stored injs/helper.jsvariables.
Follow your instructors!
@cwpittman
+jameswilliams